#!/bin/bash

set -e

echo "=> Begin create tomcat https!"
sed -i -r 's/<\/Server>//' ${CATALINA_HOME}/conf/server.xml
sed -i -r 's/<\/Service>//' ${CATALINA_HOME}/conf/server.xml
echo '    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true">' >> ${CATALINA_HOME}/conf/server.xml
echo '      <SSLHostConfig>' >> ${CATALINA_HOME}/conf/server.xml
echo '         <Certificate certificateKeystoreFile="/etc/cas/server.keystore" certificateKeyAlias="tomcat" certificateKeystorePassword="123456"  type="RSA" />' >> ${CATALINA_HOME}/conf/server.xml
echo '      </SSLHostConfig>' >> ${CATALINA_HOME}/conf/server.xml
echo '    </Connector>' >> ${CATALINA_HOME}/conf/server.xml
echo '  </Service>' >> ${CATALINA_HOME}/conf/server.xml 
echo '</Server>' >> ${CATALINA_HOME}/conf/server.xml 
echo "=> Done!"

